import { moduleRequest, baseRequest } from "./axios";

const LOGIN_URL = "doLogin";
const LOGOUT_URL = "doLogout";
const USERINFO_URL = "getLoginUser";

export type LoginResponse = {
  code: number;
  data: string;
  msg: string;
};

const request = moduleRequest(`/auth/b/`);
export default {
  login(username: string, password: string) {
    return request(
      LOGIN_URL,
      {
        account: username,
        password,
        validCode: "",
        validCodeReqNo: "",
      },
      "post"
    );
  },
  logout() {
    return request(LOGOUT_URL, undefined, "GET");
  },
  getUserInfo() {
    return request(USERINFO_URL, undefined, "GET");
  },
  updatePwd(obj) {
    return baseRequest("/sys/userCenter/updatePassword", obj, "post");
  },
  loginCas(obj) {
    return baseRequest("/auth/c/casLogin", obj, "post");
  },
};
